import { EventTarget } from 'cc'

type EventCallback = (...args: any[]) => void

export class EventManager {
    private static eventTarget: EventTarget = new EventTarget()

    public static emit(eventName: string, ...args: any[]): void {
        this.eventTarget.emit(eventName, ...args)
    }

    public static on(eventName: string, callback: EventCallback, target?: any): void {
        this.eventTarget.on(eventName, callback, target)
    }

    public static off(eventName: string, callback: EventCallback, target?: any): void {
        this.eventTarget.off(eventName, callback, target)
    }
}